package com.im.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.im.dao.CarDAO;
import com.im.dao.MemberDAO;
import com.im.entity.Car;
import com.im.entity.Member;


@WebServlet("/carpost")
public class CarPostServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String message = "";
		
			String priceStr = request.getParameter("price");
			
		
			Car car = new Car();
			car.setTitle(request.getParameter("title"));
			car.setDescription(request.getParameter("description"));
			car.setBrand(request.getParameter("brand"));
			car.setModel(request.getParameter("model"));
			car.setPrice(Double.parseDouble(priceStr));
			car.setImage("images/car.png");
			message = CarDAO.insert(car);
			
		
		
		PrintWriter out = response.getWriter();
		out.println("<h1>"+message+"</h1>");
	}

}
